!!MP	inlines.f
	program hotlis
c
c   Hotlist2HTML
c
c   Read the NCSA Mosaic (V. 1.0.2) Hotlist and generates a HTML page
c   from it. Output is written to a user selectable file.
c
c   Compilation of this program requires the Language Systems Fortran 3.0
c   compiler or a later Version, running under MPW 3.2.3.
c   Furthermore, System 7 Toolbox routines are called. 
c
c   Lutz Weimann   Version 0.6     14.1.94
c
	implicit none
c
!!I		Standardfile.f
c
	logical export
	parameter (export=.true.)
	integer outunit
	parameter (outunit=20)
c
c
	external WriteHTMLHotlist
	integer*2 refnum, vRefNum, err
	pointer /ptr/ menuh, urlsh
	record /SFTypeList/ MyTypes
	record /StandardFileReply/ ReplyRecord
	string*255 HotlistName, thestring
c
	if (export) call InitialAboutBox()
c
	MyTypes.OSTy(0)='HOTL'
	Call StandardGetFile(nil,Int2(1),MyTypes,ReplyRecord)
	if (.not.ReplyRecord.sfGood) stop 'Hotlist selection canceled!'
	HotlistName = ReplyRecord.sfFile.name
	call F_SetDefaultFileName (HotlistName//'.html')
	open (20,file=*'Save HTML page as:',status='new')
c
	refnum = FSpOpenResfile(ReplyRecord.sfFile,Int1(1))
	if (ResError().ne.0) stop 'OpenResfile: Cannot open Hotlist!'
c
	call UseResFile(refnum)
	if (ResError().ne.0) stop 'UseResFile failed!'
c
	thestring = 'Menu'
	menuh = GetNamedResource('STR#',thestring)
	if (ResError().ne.0) stop 'Cant find STR# Resource Menu!'
c
	thestring = 'URLs'
	urlsh = GetNamedResource('STR#',thestring)
	if (ResError().ne.0) stop 'Cant find STR# Resource URLs!'
c
	call WriteHTMLHotlist(outunit, HotlistName, 
     $                    %val(menuh^.p), %val(urlsh^.p))
c
	close(outunit)
 	call CloseResFile(refnum)
	if (ResError().ne.0) stop 'CloseResFile failed!'
	end
c
c
	subroutine WriteHTMLHotlist(outunit, HotlistFileName, Menu, URLs)
	implicit none
	integer outunit
	string*255 HotlistFileName
	integer*1 Menu(*), URLs(*)
c
	integer numMenu, numURLs, ptrMenu, ptrURLs, lMenu, lURLs,
     $      i, j, loopbound
	character*255 CharMenuBuf, CharURLsBuf
	integer*1 IntMenuBuf(255), IntURLsBuf(255)
	equivalence (CharMenuBuf,IntMenuBuf), (CharURLsBuf,IntURLsBuf)
	string*255 Message
	character*9 datestring
c
	numMenu = Menu(1)*256+Menu(2)
	numURLs = URLs(1)*256+URLs(2)
	if (numMenu.ne.numURLs) then
		Message = 'Different number of menuitems and URLs found.'//
     $            'I generate a list of the lower number length'
		call AlertBox(Message)
	endif
	write(20,1001) HotlistFileName
	loopbound = min(numMenu, numURLs)
	ptrMenu = 3
	ptrURLs = 3
	do i=1,loopbound
		lMenu = Menu(ptrMenu)
		do j=1,lMenu
			IntMenuBuf(j) = Menu(ptrMenu+j)
		enddo
		ptrMenu = ptrMenu+lMenu+1
		lURLs = URLs(ptrURLs)
		do j=1,lURLs
			IntURLsBuf(j) = URLs(ptrURLs+j)
		enddo
		ptrURLs = ptrURLs+lURLs+1
		write(outunit,1002) CharURLsBuf(1:lURLs),CharMenuBuf(1:lMenu)
	enddo
	call date(datestring)
	write(outunit,1003) HotlistFileName,datestring
	return
c
1001  format('<TITLE>',a,'</TITLE>',/,'<UL>')
1002  format('<LI> <A HREF= "',a,'">',a,'</A>')
1003  format('</UL>',/,'<ADDRESS>Generated from ',a,' at ',a,'</ADDRESS>',/)
	end
c
c
	Subroutine InitialAboutBox()
	implicit none
c
!!I	Dialogs.f
!!I	Events.f
c
	integer*2 AboutDialogID
	parameter (AboutDialogID=32002)
c
	record /EventRecord/ theEvent
	record /DialogRecord/ AboutDialog
	record /DialogPtr/ AboutDialogPtr
	integer*2 itemhit
	logical status
c
	call InitDialogs(nil)
	AboutDialogPtr = GetNewDialog(AboutDialogID, %ref(AboutDialog), -1)
c
	do while (.not.GetNextEvent(mDownMask,theEvent))
		if (GetNextEvent(updateMask,theEvent)) then
			if (.not.IsDialogEvent(theEvent)) cycle
			status = DialogSelect(theEvent,%ref(AboutDialogPtr),%ref(itemhit))
		endif
	enddo
	call DisposDialog(AboutDialogPtr)
	return
	end
	
	
	
	